//
//  VisitorLoginView.swift
//  Weibo-DG-test
//
//  Created by Lang on 10/9/15.
//  Copyright © 2015 Lang. All rights reserved.
//

import UIKit

class VisitorLoginView: UIView {

    /*
    // Only override drawRect: if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func drawRect(rect: CGRect) {
        // Drawing code
    }
    */
    
    override init(frame: CGRect) {
        super.init(frame:frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        
        // 禁止用 sb/xib使用本类
//        fatalError("init(coder:) has not been implemented")
   
        super.init(coder: aDecoder)
        
    }

    // 设置界面
    private func setupUI(){
        
        addSubview(iconView)
        addSubview(homeIconView)
        addSubview(messageLabel)
        addSubview(registerButton)
        addSubview(loginButton)
        
        // 自动布局
        addConstraint(NSLayoutConstraint(item: iconView, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.CenterX, multiplier: 1.0, constant: 0))
       addConstraint(NSLayoutConstraint(item: iconView, attribute: NSLayoutAttribute.CenterY, relatedBy: NSLayoutRelation.Equal, toItem: self, attribute: NSLayoutAttribute.CenterY, multiplier: 1.0, constant: 0))
    }
    
    // MARK: - 懒加载控件
    ///  小图标
    private lazy var iconView: UIImageView = {
        let iconView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_smallicon"))
        
        return iconView
    }()
    
    /// 小房子
    private lazy var homeIconView: UIImageView = {
        let homeIconView = UIImageView(image: UIImage(named: "visitordiscover_feed_image_house"))
        
        return homeIconView
    }()
    /// 消息文字
    private lazy var messageLabel: UILabel = {
        let messageLabel = UILabel()
        messageLabel.text = "关注一些人，回这里看看有什么惊喜"
        
        return messageLabel
    }()
    /// 注册按钮
    private lazy var registerButton: UIButton = {
    
        let button = UIButton()
        button.setTitle("注册", forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
        
        return button
    }()
    /// 登录
    private lazy var loginButton: UIButton = {
        
        let button = UIButton()
        button.setTitle("登录", forState: UIControlState.Normal)
        button.setBackgroundImage(UIImage(named: "common_button_white_disable"), forState: UIControlState.Normal)
        
        return button
        }()
}
